﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MpSoft.Library.DAO.Products;
using MpSoft.Library.DTO;
using MpSoft.Basic.Configuration;

namespace MpSoft.Library.BUSS.Products
{
    #region  ProductLanguage

    public class ProductLanguageBUSS
    {
        private const string PRODUCTLANGUAGE_ALL_KEY = "Mp.productlanguage.all-{0}";
        private const string PRODUCTLANGUAGE_BY_ID_KEY = "Mp.productlanguage.id-{0}";

        private static void ProductLanguageRemoveCache()
        {
            MpCache.RemoveByPattern(PRODUCTLANGUAGE_ALL_KEY);
            MpCache.RemoveByPattern(PRODUCTLANGUAGE_BY_ID_KEY);
        }

        public static int ProductLanguage_Add(ProductLanguage obj)
        {
            var result = ProductLanguageDAO.ProductLanguage_Add(obj);
            return result;
        }
        public static int ProductLanguage_Update(ProductLanguage obj)
        {
            var result = ProductLanguageDAO.ProductLanguage_Update(obj);
            return result;
        }

        public static int ProductLanguage_Delete(int PLID)
        {
            var result = ProductLanguageDAO.ProductLanguage_Delete(PLID);
            return result;
        }

        public static ProductLanguage ProductLanguage_ByID(int PLID)
        {
            var list = ProductLanguage_Select(PLID, -1, null);
            if (list != null)
                return list.FirstOrDefault();
            return null;
        }

        public static ProductLanguage ProductLanguage_ByID(int ProductID, string LanguageCode)
        {
            var list = ProductLanguage_Select(-1, ProductID, LanguageCode);
            if (list != null)
                return list.FirstOrDefault();
            return null;
        }

        public static List<ProductLanguage> ProductLanguage_Select(int PLID, int ProductID, string LanguageCode)
        {
            return ProductLanguageDAO.ProductLanguage_Select(PLID, ProductID, LanguageCode);
        }
    }

    #endregion
}
